
async function processImageApi(backend_domain_name, token, classes, image){
    console.log('类别：' + classes)
    if (!classes) {
        return { TF: false, message: '未传入 classes 值或 classes 值为空' };
    }
    
    if (!Array.isArray(classes)) {
        return { TF: false, message: 'classes 值不是列表类型' };
    }
    if (!image) {
        return { TF: false, message: '未传入 image 文件' };
    }
    
    try {
        const formData = new FormData();
        formData.append('token', token);
        formData.append('classes', JSON.stringify(classes));
        formData.append('image', image);
        
        const response = await fetch(backend_domain_name + '/image_processing/process_image', {
            method: 'POST',
            body: formData
        });
        
        const result = await response.json();
        if (result.TF === 'T') {
            console.log('图片处理结果: ' + result.data)
            return { TF: true, data: result.data };
        } else {
            return { TF: false, message: result.message };
        }
    } catch (error) {
        console.error('请求图片处理服务失败:', error);
        return { TF: false, message: '请求图片处理服务失败: ' + error.message };
    }
}
async function checkToken(backend_domain_name, token) {
    const formData = new URLSearchParams();
    formData.append('token', token);

    try {
        const response = await fetch(backend_domain_name + '/image_processing/check_token', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: formData
        });

        const data = await response.json();
        if (data.TF === 'T') {
            return true;
        } else {
            console.log(data.message)
            return false;
        }
    } catch (error) {
        console.error('请求错误:', error);
        return null;
    }
}